package com.example.onlinemarket.dao;


import com.example.onlinemarket.bean.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.io.InputStream;
import java.util.List;

@Mapper
public interface UserDao {
    User getUserByName(String userName);//按用户名获取用户对象
    Boolean canUserLoginByUserName(@Param("userName")String userName, @Param("password")String password);//判断用户能否登录
    Boolean canUserLoginByEmail(@Param("email")String email, @Param("password")String password);//判断用户能否登录
    boolean checkUserNameExist(String userName);//检查用户是否存在
    boolean checkEmailExist(String email);//检查邮箱是否存在
    int addUser(User user);//添加新用户(用户注册)
    int updateUserHeadImg(@Param("userName")String userName, @Param("photo")InputStream is);//更新用户头像
    int updateUserInfoWithImg(@Param("user")User user, @Param("newPhoto")InputStream is);//带有头像上传的用户资料更新
    int updateUserInfoWithoutImg(@Param("user")User user);//不带头像更新的资料更新
    Integer checkForUserSearching(String searchContent);//模糊查询是否存在此类用户(商家)
    //按用户名模糊分页查询用户
    List<User> searchForUserByPages(@Param("searchContent") String searchContent, @Param("recorded") Integer recorded, @Param("pageSize") Integer pageSize);
    User getUserById(Integer userId);//按用户ID获取用户对象
    String getUserNameById(Integer shopId);//按用户ID获取用户名
    User getUserByEmail(String email);//按用户Email获取用户对象
    boolean updateUserAddress(@Param("userId") Integer userId, @Param("address") String address);
    boolean updateUserPassword(@Param("userName") String userName, @Param("password") String password);
    boolean updateAddress(@Param("userName")String userName, @Param("address")String address);
    boolean updateUserEmail(@Param("userName")String userName, @Param("email")String email);

    boolean updatePayPassword(@Param("userId")int userId, @Param("payPassword") String payPassword);
}
